home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Medal Software 3
/
Gold Medal Software - Volume 3 (Gold Medal) (1994).iso
/
utils2
/
t2b120a.arj
/
TXT2BIN.DOC
< prev
next >
Wrap
Text File
|
1994-01-27
|
16KB
|
532 lines
TXT2BIN - Text-To-Binary Conversion Program
Version 1.20 (January 3, 1994)
Copyright 1992,1993,1994 Bruce Lum
DISCLAIMER
----------
The TXT2BIN program is provided "AS-IS". You use this program
strictly at your own risk. No warranty of any kind exists. The
author is not responsible for any incidental or consequential
damages to your computer or the data stored on it as a result of
misuse or the inability to run the program. By running TXT2BIN,
you agree to this.
TRADEMARKS
----------
HP, LaserJet, DeskJet and PCL are U.S. registered trademarks of
Hewlett-Packard Company.
IBM and Proprinter are registered trademarks of International
Business Machines Corporation.
Epson is a registered trademark of Seiko Epson Corporation.
INTRODUCTION
------------
TXT2BIN is a utility program for the IBM PC (or compatible) that
helps you to create and maintain a binary file by describing the
contents in the form of a text file.
In contrast, you could create or modify a binary file with a hex
editor or a debugger. However, you may be restricted to the use
of hexadecimal numbers, in addition to ASCII text. Also, a
binary file may be all that you are left with. Documented
changes to the file may have to exist elsewhere.
What can you do with TXT2BIN? Here is an application:
A text file describes the initial settings of a dot-matrix or
laser printer, with documentation in the file. TXT2BIN
translates this text file into the equivalent binary
information and sends it to the printer.
With TXT2BIN, you can work with any base (e.g. decimal,
hexadecimal, etc.) that you feel comfortable with. Any changes
can be accompanied by comments in the text file. Symbols can
also be used to represent bytes in a more legible way.
To use TXT2BIN, all you need is a text editor to describe the
contents of the binary file. From the text file, TXT2BIN creates
the binary file for you. If the binary file ever needs any
changes, you can make them in the text file and run TXT2BIN
again.
COMMAND SYNTAX
--------------
To run TXT2BIN from the DOS prompt, use the following syntax:
TXT2BIN [option...] <textfile> <target>
where:
[option] is one or more special instructions to be used
during the conversion process;
<textfile> is the name of the file that contains the textual
representation of the individual bytes in the binary file;
<target> is the name of the file or device that will receive
the bytes resulting from the conversion process.
THE TEXT FILE
-------------
The text file consists of one or more lines (or records) that
describe the contents of the binary file.
To create the text file, use a text editor or word processor that
can save files in the ASCII text format. Non-ASCII files may
produce error messages during the conversion process.
You can use any ASCII character whose value falls within the
following ranges (inclusive):
(a) 21 - FF (hexadecimal), or 33 - 255 (decimal);
(b) SPACE: 20 (hex) or 32 (dec);
(c) TAB: 9 (hex/dec);
(d) FORM-FEED: 0C (hex) or 12 (dec)
Each line in the text file can contain any of the following:
(a) a list of bytes
(b) a text string
(c) a comment
(d) a directive
(e) a combination of the above
(f) a blank line
The first four (4) types are discussed in detail below.
Representation of Individual Bytes
----------------------------------
Each byte must be composed of alphabetic and/or numeric
characters conforming to the radix (base) that is currently in
effect.
Examples:
If the radix is 2, then the characters that
make up the byte can only be 0 and 1.
If the radix is 8, then the characters that
make up the byte can only be from 0 to 7 (inclusive).
With a radix greater than 10, use the alphabetic characters
(starting from the letter A) to represent the digits higher than
9.
Examples:
If the radix is 12, then the characters that make up
the byte can only be from 0 to 9 (inclusive), and the
letters A and B (to represent 10 and 11, respectively).
If the radix is 16, then the characters that make up
the byte can only be from 0 to 9 (inclusive) and from A
to F (inclusive). The letters from A to F will represent
the digits from 10 to 15, respectively.
Regardless of the radix, the total value of each byte must be
between 0 to 255 (inclusive).
Leading zeroes are not required, and you must have spaces between
the bytes.
Examples (all representing a set of identical bytes):
1B 26 6C 31 4F (radix=16: HEXADECIMAL)
27 38 108 49 79 (radix=10: DECIMAL)
33 46 154 61 117 (radix=8: OCTAL)
00011011 00100110 01101100 00110001 01001111
(radix=2: BINARY !!)
Text Strings
------------
The text string enclosed by a pair of double quote characters.
Examples:
"%-12345X"
"A text string"
Escape sequences may also be part of a text string.
Example:
"\fA text string\n"
(For more details, see the following section called "Escape
Sequences in Text Strings".)
For double quotes, precede them with a backslash character (\).
For example, if the text string is
PARM="CD-ROM AVAILABLE";
then you must set it up as follows:
"PARM=\"CD-ROM AVAILABLE\";"
Escape Sequences in Text Strings
--------------------------------
The escape sequence allows certain hard-to-get characters (such
as control codes) to be represented. These characters usually
cannot be entered from within the text editor or word processor.
An escape sequence starts with the backslash character (\) and is
followed by one or more octal, hexadecimal or ASCII characters.
Here is the list of escape sequences that TXT2BIN currently
supports:
Sequence Value Char Description
\a 0x07 BEL Bell (Alert)
\b 0x08 BS Backspace
\f 0x0C FF Formfeed
\n 0x0A LF Newline
\r 0x0D CR Carriage return
\t 0x09 HT Horizontal tab
\v 0x0B VT Vertical tab
\' 0x27 ' Single quote (apostrophe)
\? 0x3F ? Question mark
\" 0x22 " Double quote
\\ 0x5C \ Backslash
\Onnn (any) 'nnn' is a string of up to 3
octal digits
\Xhh (any) 'hh' is a string of hex digits
\xhh (any) 'hh' is a string of hex digits
\nnn (any) 'nnn' is a string of up to 3
octal digits
Examples:
"\aFatal error!\r\n"
"The \"right\" way of using double-quotes"
"The ESC code is represented by \033"
"The ESC code is represented by \x1B"
"The ESC code is represented by \X1B"
"The ESC code is represented by \O033"
Comments
--------
A comment starts with a semi-colon. Anything to the right of the
semi-colon is completely ignored by TXT2BIN. The comment can
start anywhere on the line.
Example:
;-------------------------------------------------
; These three entire lines are ignored by TXT2BIN
;-------------------------------------------------
27 "1@" ; This part of the line will be ignored
Directives
----------
These are instructions asking TXT2BIN to take some form of
action. Although directives can appear anywhere in the text
file, and as often as required, only one directive is allowed on
a line.
A directive starts with a period (.) and is followed by a special
keyword. Other parameters may follow the keyword.
This version of TXT2BIN supports the following directives:
(a) DEFINE
(b) INCLUDE
(c) RADIX
These directives are described below.
.DEFINE Symbol Replacement
What this means to TXT2BIN is "After this line, if you ever
encounter <Symbol> later in the text file (except within a
comment), replace it with the contents of Replacement". This
is useful if one or more bytes can be commonly identified by
a symbolic name.
The name of the symbol, "Symbol", must start with an
alphabetic character (A-Z, a-z), followed by a mixture of
alphabetic, numeric (0-9), and underscore (_) characters.
The maximum length of a symbol is 32 characters.
Within the name of a symbol, an alphabetic letter can either
be lowercase or uppercase; there is no distinction. Thus,
the symbols "Esc" and "ESC" are considered as identical.
"Replacement" is a sequence of bytes, strings, and symbols
that you intend to replace <Symbol> with during the
conversion process. You may also include comments. The
maximum length of "Replacement" is 255 characters (including
comments).
Example:
.DEFINE Esc 27 ; Replace <Esc> with 27
.DEFINE CR_LF 13 10 ; Replace <CR_LF> with 13 10
<Esc> "&l1T" <CR_LF>
; TXT2BIN replaces <Esc> and <CR_LF>, so that the
; line will be processed as:
;
; 27 "&l1T" 13 10
.INCLUDE FileName
This directive allows you to insert lines from a specified
file into your text file.
When this directive is encountered, TXT2BIN reads and
processes the lines in the file called "FileName". After all
the lines are processed, TXT2BIN continues with the line
following the INCLUDE directive.
The two files DEFINES.10 and DEFINES.16 (contained in your
TXT2BIN package) defines the list of ASCII control characters
(in decimal and the other in hexadecimal, respectively).
Instead of having to type the definitions repeatingly for all
your text files, you can use the INCLUDE directive to refer
to one of the two files.
Examples:
.INCLUDE defines.10
.INCLUDE Z:\PUBLIC\TXT2BIN\INCLUDE\defines.16
.RADIX nn
This changes the radix (number base) to any value between 2
to 36, inclusive. 'nn' is the value of the desired radix, in
decimal. The default radix value is 10 (that is, the decimal
numbering system).
Examples:
.RADIX 10 ; Change base to 10 (DECIMAL)
.RADIX 16 ; Change base to 16 (HEXADECIMAL)
.RADIX 8 ; Change base to 8 (OCTAL)
.RADIX 2 ; Change base to 2 (BINARY)
ERROR MESSAGES
--------------
During TXT2BIN's processing of the contents of the text file,
messages may appear as a result of one or more encountered
errors. Each message will also identify the exact location of
the error by telling you the line and column number.
Error messages can also be redirected to a file or device. Here
are some examples:
TXT2BIN filename.txt filename.bin >error.msg
TXT2BIN filename.txt filename.bin >NUL
TXT2BIN filename.txt filename.bin >LPT1
The complete list of error messages can be found in the file
called TXT2BIN.MSG that comes with the TXT2BIN program.
COMMAND-LINE OPTIONS
--------------------
Only one option is currently available in TXT2BIN that you can
use during the conversion process.
-q QUIET switch. This option eliminates all status and
error messages that are normally displayed on the
screen.
Example:
TXT2BIN -q INFILE.TXT OUTFILE.BIN
EXAMPLE
-------
The following text file contains a set of commands that
initializes a HP LaserJet IIISi printer.
(This can be found in the file called EXAMPLE.HPL that comes with
the TXT2BIN program.)
;-----------------------------------------------------------
; EXAMPLE.HPL
;
; This text file contains the instructions to initialize a
; HP LaserJet IIISi (or 4) printer
;
; (Use the TXT2BIN program to create the binary image file)
;
; HP, PCL and LaserJet are U.S. registered trademarks of
; Hewlett-Packard Company.
;-----------------------------------------------------------
.RADIX 16 ; Set base to hexadecimal
.INCLUDE defines.16 ; Include list of control
; codes (in hexadecimal)
;--------------------------------------
; Job Control
;--------------------------------------
<Esc> "%-12345X" ; Universal Exit Language /
; Start of PJL
"@PJL ENTER LANGUAGE=PCL" <LF> ; Enter PCL mode
<Esc> "E" ; Reset the printer
<Esc> "&l1X" ; Number of copies = 1
<Esc> "&l1S" ; Duplex, long-edge binding
;--------------------------------------
; Page Control
;--------------------------------------
<Esc> "&l0O" ; Page orientation: Portrait
<Esc> "&l2A" ; Page size: Letter
<Esc> "&l6D" ; Line spacing: 6 lines/inch
<Esc> "&l1E" ; Select upper output bin
<Esc> "&l60F" ; Text length: 60 lines
<Esc> "&l1H" ; Main paper source feed
DISTRIBUTION
------------
You may freely distribute the TXT2BIN package, provided that the
following files are distributed together:
TXT2BIN.EXE The TXT2BIN program
TXT2BIN.DOC The documentation file for TXT2BIN
TXT2BIN.MSG List of error messages from TXT2BIN
README.1ST Installation procedure, list of latest
changes, and any last-minute information
(this file)
DEFINES.10 List of ASCII control character definitions
(in decimal or base 10)
DEFINES.16 List of ASCII control character definitions
(in hexadecimal or base 16)
EXAMPLE.ESN Text file to reset Epson LQ-2500 printer
EXAMPLE.HPD Text file to reset HP DeskJet printer
EXAMPLE.HPL Text file to reset HP LaserJet printer
EXAMPLE.IBM Text file to reset IBM Proprinter printer
BIN2TXT.EXE A supplemental program that converts a binary
file into a textual representation
BIN2TXT.DOC The documentation file for BIN2TXT
CONTRIBUTIONS
-------------
If you find TXT2BIN useful, please send $10.00 (in U.S. funds) or
$12.00 (in Canadian funds) to the author at the postal address
below. If you have access to Compuserve or Internet, please
include your ID/address; you will be notified of any updates or
new products.
Your support is greatly appreciated.
CORRESPONDENCE
--------------
If you have any problems, questions, or any type of feedback,
electronic mail may be sent to the author (Bruce Lum) at the
following addresses:
Compuserve: 72727,3104
Internet: 72727.3104@compuserve.com
If you are using the postal service, the address is:
Bruce Lum
P.O. Box 5098, Station A
Toronto, Ontario
CANADA M5W 1N4